package com.itHsuSE.smallchange.oopTest;

public class Test {
    public static void main(String[] args) {
        Student student = new Student("晓明", '男', 15, "00002323");
        student.printInfo();

        Person[] persons=new Person[4];
        persons[0]=new Student("jack",'男',10,"0001");
        persons[1]=new Student("smith",'男',30,"0002");
        persons[2]=new Teacher("john",'男',50,10);
        persons[3]=new Teacher("wall",'男',5,20);

        bubbleSort(persons);

        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i]);
        }
    }

    public static void bubbleSort(Person[] persons){
        Person temp=null;
        boolean flag=false;
        for (int i = 0; i < persons.length-1; i++) {
            for (int j = 0; j < persons.length-1-i; j++) {
                if(persons[j].getAge()<persons[j+1].getAge()){
                    temp=persons[j];
                    persons[j]=persons[j+1];
                    persons[j+1]=temp;
                    flag=true;
                }
            }
            if(!flag){
                break;
            }
        }
    }
}
